package gl.web.apk.controller;


import gl.web.apk.common.model.Blog;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

/**
 * BlogValidator.
 */
public class BlogValidator extends Validator {
	
	protected void validate(Controller controller) {
		validateRequiredString("apk.versionname", "versionname", "不能为空");
		validateRequiredString("apk.versioncode", "versioncode", "不能为空");
	}
	
	protected void handleError(Controller controller) {
		controller.keepModel(Blog.class);
		
		String actionKey = getActionKey();
		if (actionKey.equals("/apk/save"))
			controller.render("add.html");
		else if (actionKey.equals("/apk/update"))
			controller.render("edit.html");
	}
}
